<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue.js"></script>
    <script src="lib/vue-router.js" type="application/javascript"></script>
</head>
<body>
<div id="app">
    {{msg}}<br/>
    <router-link to="/login">登陆</router-link>
    <router-link to="/register">注册</router-link>
    <router-view></router-view>
</div>
<template id="child1">
    <div>这是组件</div>
</template>
<script>
    var login = {
        template: '<h1>登录</h1>'
    }
    var register = {
        template: '<h1>注册</h1>'
    }
    let router = new VueRouter({
        routes: [
            {path: "/", redirect: '/login'},
            {path: '/login', component: login},
            {path: '/register', component: register}
        ]
    });
    new Vue({
        el: '#app',
        data: {
            msg: '你好'
        },
        router
    })
    // 组件components，{login} 才生效，component 反而没有生效
</script>
</body>
</html>
